//
//  OPBoard_Extensions.m
//  OPFramework
//
//  Created by malcom on 7/23/08.
//  Copyright 2008 malcom-mac software. All rights reserved.
//

#import "OPBoard_Extensions.h"


@implementation OPBoard (OPBoard_Extensions)

- (int) getPostPageIdxOf:(NSNumber *) _postID inTopic:(NSNumber *) _topicID ofForum:(NSNumber *) _forumID {	
	XMLRPCResponse *dataMessage = [self _executeRequestMethodNamed: @"msgs.getPageIndexForPostWithID" 
																  withParams: [NSArray arrayWithObjects: 
																			   _postID,
																			   _topicID,
																			   _forumID,
																			   [obj_boardConfig getPropertyForKey:OPBoardConfig_PostsPerPage],nil]
															  attachAuthData: NO];
	if (![dataMessage isFault])
		return [[dataMessage responseObject] intValue];
	else return -1;
}

- (NSArray *) getBoardLeaders {
	XMLRPCResponse *dataMessage = [self _executeRequestMethodNamed: @"stats.getBoardAdmins" 
														withParams: nil
													attachAuthData: NO];
	NSMutableArray *list = [[NSMutableArray alloc] init];
	if (![dataMessage isFault]) {
		NSArray *users = [dataMessage responseObject];
		for (NSDictionary *cUser in users) {
			OPUser *_user = [obj_membersCache getUserMemberFromID: [cUser objectForKey: @"user_id"] withName: [cUser objectForKey: @"username"]];
			[list addObject: _user];
		}
		return [list autorelease];
	} else return nil;
}

@end
